package au.com.iglootech.winerymap.entity;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

/**
 * 
 * @author Nicholas Zhu
 * 
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class WineryNews implements IGTDomainEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7819798603940201511L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private Date date;

	@Persistent
	private Key wineryKey;

	@Persistent
	private String title;

	@Persistent
	private String content;

	@Persistent
	private Integer priority;

	@Override
	public Key getKey() {
		return key;
	}

	@Override
	public void setKey(final Key key) {
		this.key = key;
	}

	@Override
	public String toLogString() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Key createBy() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * @param date
	 *            the date to set
	 */
	public void setDate(final Date date) {
		this.date = date;
	}

	/**
	 * @return the wineryKey
	 */
	public Key getWineryKey() {
		return wineryKey;
	}

	/**
	 * @param wineryKey
	 *            the wineryKey to set
	 */
	public void setWineryKey(final Key wineryKey) {
		this.wineryKey = wineryKey;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(final String title) {
		this.title = title;
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(final String content) {
		this.content = content;
	}

	/**
	 * @return the priority
	 */
	public Integer getPriority() {
		return priority;
	}

	/**
	 * @param priority
	 *            the priority to set
	 */
	public void setPreority(final Integer priority) {
		this.priority = priority;
	}

	/**
	 * 
	 * @return string of key
	 */
	public String getKeyValue() {
		return KeyFactory.keyToString(key);
	}

	/**
	 * 
	 * @param keyValue
	 *            string of key
	 */
	public void setKeyValue(final String keyValue) {
		key = KeyFactory.stringToKey(keyValue);
	}

}
